package com.koron.css2.baseConfig.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.baseConfig.bean.TradeClassifyBean;
import com.koron.css2.baseConfig.mapper.TradeClassifyMapper;
import com.koron.css2.baseConfig.queryBean.TradeClassifyQueryBean;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;
/**
 * 行业分类-编辑初始化
 * 
 * @author 李攀
 *
 */
public class TradeClassifyQuery implements ServerInterface {
	
private static Logger logger = LogManager.getLogger(TradeClassifyQuery.class);
	
	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {

		@SuppressWarnings("rawtypes")
		MessageBean<TradeClassifyBean> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", TradeClassifyBean.class);

		try {
			TradeClassifyQueryBean bean = JsonUtils.objectToPojo(req.getData(), TradeClassifyQueryBean.class);
			TradeClassifyMapper mapper = factory.getMapper(TradeClassifyMapper.class);
			TradeClassifyBean TradeClassifybean = mapper.selectTradeClassifyById(bean.getId());
			info.setData( TradeClassifybean);
		} catch (Exception e) {
			info.setCode(Constant.MESSAGE_INT_FAIL);
			info.setDescription(e.getMessage());
			logger.error(e.getMessage(), e);
		}
		return info;
	}
	
	
}
